###########################################################################
#                            TextMate Snippets                            #
###########################################################################
snippet get "Get Elements"
getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')
endsnippet

snippet '':f "object method string"
'${1:${2:#thing}:${3:click}}': function(element){
	$0
}${10:,}
endsnippet

snippet :f "Object Method"
${1:method_name}: function(${3:attribute}){
	$0
}${10:,}
endsnippet

snippet :, "Object Value JS"
${1:value_name}: ${0:value},
endsnippet

snippet : "Object key key: 'value'"
${1:key}: ${2:"${3:value}"}${4:, }
endsnippet

snippet proto "Prototype (proto)"
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) ,,{
};

endsnippet

snippet for "for (...) {...} (faster)"
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){
	${3:$1[$2]}$0
};
endsnippet

snippet for "for (...) {...}"
for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) {
	${3:$1[$2]}$0
};
endsnippet

snippet fun "function(fun)"
function ${1:function_name}(${2:argument}) {
}
endsnippet

snippet (fun "(function(fun)"
(function ${1:function_name}(${2:argument}) {
}
endsnippet

snippet afn "anonymous function"
function(${1:argument}) {
}
endsnippet

snippet (afn "anonymous function"
(function(${1:argument}) {
}
endsnippet

snippet ret "Return statement"
return ${VISUAL}$0
endsnippet


snippet ife "if ___ else"
if (${1:true}) {$0} else{}
endsnippet

snippet main "fun main"
function main() {
	${0:${VISUAL}}
}
endsnippet

snippet if "if"
if (${1:true}) {$0}
endsnippet

snippet timeout "setTimeout function"
setTimeout(function() {$0}${2:}, ${1:10});
endsnippet

snippet	jsdoc
/**
 * $1
 * @return
 */
endsnippet

snippet dlog
debug.log("$1")
endsnippet

snippet clog
console.log("$1")
endsnippet

snippet super "super in backbone extend"
this.constructor.__super__.
endsnippet

snippet _.each "_.each"
_.each(${1:Iterable}, function(item, index) {
	${2}
})
endsnippet

snippet us "use strict"
'use strict'
endsnippet

snippet foreach "forEach ->"
$1.forEach(function(${2:item}, ${3:i}) {
	$4
})
endsnippet

snippet tc "try catch"
try {
	$1
} catch(err) {
	$2
}
endsnippet

snippet prom "Promise"
new Promise((resolve, reject) => {
})
endsnippet

snippet met "method"
$1() {
}
endsnippet

snippet aff "fat arrow method"
($1) => {
}
endsnippet

snippet flow "flow" b
/* @flow */
endsnippet

snippet floww "flow weak" b
/* @flow weak */
endsnippet

snippet m "method" b
$1() {
}
endsnippet

snippet ecls "ecma class"
class ${1:Class}${2: extends ${3:Parent}} {
}
endsnippet

snippet cwfn "console with current filename"
console.log('[${1:`!v expand('%:r')`}]', $2)
endsnippet

#########
#  Vue  #
#########

snippet vuedatafn "vue data()"
  data() {
    return {
			$1
		}
  },
endsnippet

snippet vccprop "vue class component @Prop"
@Prop() ${VISUAL}$1: ${2:type}
endsnippet

snippet vimpc "import vue component, ultisnips"
import ${1/(.*)\/([\w]*)\.vue/$2/g} from '${1}'
endsnippet

snippet rimpc "import React component, ultisnips"
import ${1/(.*)\/([\w]*)\.tsx/$2/g} from '${1}'
endsnippet

snippet riimpc "import React component folder, ultisnips"
import ${1/(.*)\/([\w]*)\/index\.tsx/$2/g} from '${1}'
endsnippet

############
#  eslint  #
############

snippet elde "eslint disable and enable"
/* eslint-disable $1 */
/* eslint-enable $1 */
endsnippet

snippet ell "eslint disable line"
// eslint-disable-line
endsnippet

snippet eln "eslint disable next line"
// eslint-disable-next-line
endsnippet

#############
#  Modules  #
#############

# vim:ft=snippets:
